<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>项目工程计划-新增</title>
</head>
<style>
.fieldset {
	margin-top: 5px;
	margin-bottom: 0px
}

.layui-legend {
	background-color: #5fb878;
	font-size: 15px !important;
	width: 140px;
}

.layui-form-item {
	margin-bottom: 5px;
	clear: both;
	*zoom: 1;
}

.layui-form-label {
	width: 140px;
}

.layui-table, .layui-table-view {
    margin: 10px 100px;
}

</style>
<body>
	<div class="layui-fluid">
		<div class="layui-card">
			<div class="layui-tab-item layui-show">
				<div style="padding-top: 15px;">&nbsp;</div>
				<form class="layui-form" id="addInfo_form">
					<fieldset class="layui-elem-field layui-field-title fieldset"
						id="baseInfo">
						<legend class="layui-btn layui-legend"
							style="text-align: left; cursor: default;">项目基础信息 > </legend>
						<div style="margin-top: 20px">
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">申请公司</label>
									<div class="layui-input-inline">
										<input type="hidden" name="hrOrgId" value="${bindOrgId}">
										<input type="text" value="${bindOrgName}" style="border: 0px;width:220px"
											readonly="readonly" class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">申请部门</label>
									<div class="layui-input-inline">
										<input type="hidden" name="hrDeptId" value="${bindDeptId}">
										<input type="text" value="${bindDeptName}"
											style="border: 0px;" readonly="readonly" class="layui-input">
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">申请人</label>
									<div class="layui-input-inline">
										<input type="hidden" name="hrStaffApplyId"
											value="${SESSION_KEY_USER_DETAIL.hrStaffId }"> <input
											type="text" name="staffName" value="${staffName }"
											readonly="readonly" style="border: 0px" autocomplete="off"
											class="layui-input">
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">项目名称</label>
									<div class="layui-input-inline">
										<select name="buildInfoId" id="add_select_proId" lay-verify="required"
											lay-filter="add_select_proId" lay-search>
											<option value="">请选择</option>
											<c:if test="${not empty buildInfoList }">
												<c:forEach items="${buildInfoList}" var="proNames">
													<option value="${proNames.id}">${proNames.proName }</option>
												</c:forEach>
											</c:if>
										</select>
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">业态类型</label>
									<div class="layui-input-inline">
										<select lay-verify="required" name="formatType" id="query-select-format-type"
											lay-filter="query-select-format-type" lay-verify="required">
											<option value="">请选择</option>
										</select>
									</div>
								</div>
								<div class="layui-inline">
									<label class="layui-form-label">建设期（年）</label>
									<div class="layui-input-inline">
										<input type="text" value="" id ="query-input-buildYear" style="border: 0px;"
											name = "buildYears" readonly="readonly" class="layui-input">
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<div class="layui-inline">
									<label class="layui-form-label">运营期（年）</label>
									<div class="layui-input-inline">
										<input type="text" value="" id ="query-input-omYears" style="border: 0px;"
											name="omYears" readonly="readonly" class="layui-input">
									</div>
								</div>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label" style="width: 350px;">支持pdf、excel、word、图片资料，可上传多个</label>
							</div>
							<div class="layui-form-item">
								<label class="layui-form-label">分区/分段示意图</label>
								<div class="layui-input-block">
									<div class="layui-upload">
										<button type="button" class="layui-btn" id="20-upload-more">上传</button>
										<div class="layui-upload-list" id="20-upload-more-list">
										</div>
									</div>
								</div>
							</div>
						</div>
					</fieldset>
					<fieldset class="layui-elem-field layui-field-title fieldset" id="subInfo">
						<legend class="layui-btn layui-legend" style="text-align: left; cursor: default;">工程计划 > </legend>
						<div style="margin-top: 20px;" id ="mydiv">
						</div>
					</fieldset>
					<div class="layui-form-item"
						style="position: fixed ! important; right: 30px; bottom: 45%; z-index: 10000;">
						<div class="layui-input-block">
							<button
								class="layui-btn layui-bg-blue layui-btn-normal layui-btn-lg  layui-btn-radius"
								type="button" lay-submit lay-filter="addInfo_form_submit"
								id="addInfo_form_submit">
								<i class="layui-icon layui-icon-ok layuiadmin-button-btn"></i>
								提交
							</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
	<script>
	//静态资源路径前缀
	var staticPath = '${fileHttpPre}';
	var stateJSON = <infopub:dicJson groupNo="A00010028" />;

    layui.config({
        base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
    }).extend({
            index: 'lib/index' //主入口模块
        }).use([ 'index','set','upload', 'element', 'laydate'],function () {
                var $ = layui.$, form = layui.form, element = layui.element, laydate = layui.laydate,
                    upload = layui.upload;
                var formatTypes = [
                    {id: 1, name: '房建'},
                    {id: 2, name: '市政'},
                    {id: 3, name: '桥梁'},
                    {id: 4, name: '隧道'},
                    {id: 5, name: '管廊'},
                    {id: 6, name: '生态景观'}];
                var tableData =
                    [{pid: 1, id: 1, name: '土地证办理'},
                        {pid: 1, id: 2, name: '建设工程规划许可证'},
                        {pid: 1, id: 3, name: '施工许可证'},
                        {pid: 1, id: 4, name: '基础工程'},
                        {pid: 1, id: 5, name: '±0.00'},
                        {pid: 1, id: 6, name: '主体封顶'},
                        {pid: 1, id: 7, name: '装饰工程'},
                        {pid: 1, id: 8, name: '安装工程'},
                        {pid: 1, id: 9, name: '外网工程'},
                        {pid: 1, id: 10, name: '道路景观'},
                        {pid: 1, id: 11, name: '消防验收'},
                        {pid: 1, id: 12, name: '人防验收'},
                        {pid: 1, id: 13, name: '竣工验收'},
                        {pid: 2, id: 14, name: '土地证办理(土地预审)'},
                        {pid: 2, id: 15, name: '建设工程规划许可证'},
                        {pid: 2, id: 16, name: '施工许可证'},
                        {pid: 2, id: 17, name: '清表'},
                        {pid: 2, id: 18, name: '路基'},
                        {pid: 2, id: 19, name: '水稳基层'},
                        {pid: 2, id: 20, name: '沥青面层'},
                        {pid: 2, id: 21, name: '照明设施'},
                        {pid: 2, id: 22, name: '道路绿化'},
                        {pid: 2, id: 23, name: '安保设施'},
                        {pid: 2, id: 24, name: '竣工验收'},
                        {pid: 3, id: 25, name: '土地证办理'},
                        {pid: 3, id: 26, name: '建设工程规划许可证'},
                        {pid: 3, id: 27, name: '施工许可证'},
                        {pid: 3, id: 28, name: '基础'},
                        {pid: 3, id: 29, name: '承台（桥台）'},
                        {pid: 3, id: 30, name: '墩身'},
                        {pid: 3, id: 31, name: '盖梁、支座'},
                        {pid: 3, id: 32, name: '上部结构'},
                        {pid: 3, id: 33, name: '桥面铺装'},
                        {pid: 3, id: 34, name: '桥梁附属'},
                        {pid: 3, id: 35, name: '竣工验收'},
                        {pid: 4, id: 36, name: '土地证办理'},
                        {pid: 4, id: 37, name: '建设工程规划许可证'},
                        {pid: 4, id: 38, name: '施工许可证'},
                        {pid: 4, id: 39, name: '洞口工程'},
                        {pid: 4, id: 40, name: '洞身开挖'},
                        {pid: 4, id: 41, name: '洞身衬砌'},
                        {pid: 4, id: 42, name: '防排水'},
                        {pid: 4, id: 43, name: '隧道二次衬砌'},
                        {pid: 4, id: 44, name: '隧道附属工程'},
                        {pid: 4, id: 45, name: '竣工验收'},
                        {pid: 5, id: 46, name: '土地证办理(土地预审)'},
                        {pid: 5, id: 47, name: '建设工程规划许可证'},
                        {pid: 5, id: 48, name: '施工许可证'},
                        {pid: 5, id: 49, name: '清表'},
                        {pid: 5, id: 50, name: '土方开挖'},
                        {pid: 5, id: 51, name: '边坡支护'},
                        {pid: 5, id: 52, name: '结构底板'},
                        {pid: 5, id: 53, name: '结构主体'},
                        {pid: 5, id: 54, name: '回填工程'},
                        {pid: 5, id: 55, name: '安装工程'},
                        {pid: 5, id: 56, name: '竣工验收'},
                        {pid: 6, id: 46, name: '土地证办理(土地预审)'},
                        {pid: 6, id: 47, name: '建设工程规划许可证'},
                        {pid: 6, id: 48, name: '施工许可证'},
                        {pid: 6, id: 49, name: '土方开挖'},
                        {pid: 6, id: 50, name: '管网工程'},
                        {pid: 6, id: 51, name: '驳岸工程'},
                        {pid: 6, id: 52, name: '水利工程'},
                        {pid: 6, id: 53, name: '景观堆坡工程'},
                        {pid: 6, id: 54, name: '道路、广场工程'},
                        {pid: 6, id: 55, name: '建（构）造物、小品'},
                        {pid: 6, id: 56, name: '绿化工程'},
                        {pid: 6, id: 57, name: '竣工验收'}];

                var output = [];
                for (var value of formatTypes) {
                    output.push('<option value="' + value.id + '">' + value.name + '</option>');
                }
                $('#query-select-format-type').append(output.join(''));
                form.render();

                // 正则校验
                form.verify({
                    //验证汉字
                    CHS: [/^[\u0391-\uFFE5]+$/, '只能输入汉字'],
                    //大于0的正整数
                    intNumber: [/^[1-9]\d*$/, '请输入正确的数字'],
                    //数字只能有两位小数
                    floatNumber: [
                        /^([-]?)([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/,'请输入正确的数字'],
                    //数字大于0，并只能有两位小数
                    floatAmount: [
                        /^([1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/, '请输入正确的数字']
                        //var pattern=/^((\d+\.\d*[1-9]\d{1})|(\d*[1-9]\d*\.\d{2}))$/;
                });
				
                var uploadRender = function(id) {
                    upload.render({
                            elem : '#' + id + '-upload-more',
                            url : basePath
                                + '/programPlan/uploadAtt/',
                            data : {
                                types : id
                            },
                            multiple : true,
                            accept : 'file',
                            acceptMime : 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf',
                            before : function(obj) {
                                layer.load();
                            },
                            done : function(res) {
                                if (res.code > 0) {
                                    layer.closeAll('loading');
                                    return layer.msg(res.msg, {
                                        icon : 7
                                    });
                                }
                                if (res.entity != null && res.entity.length > 0) {
                                    for ( var i in res.entity) {
                                        var preProject = res.entity[i];
                                        var arr = preProject.split("|");
                                        var imgSrc = "";
                                        var suffix = arr[1].substring(arr[1].lastIndexOf(".") + 1,arr[1].length);
                                        if (suffix == 'jpg'|| suffix == 'png') {
                                            imgSrc = "${fileHttpPre}/"+ arr[3];
                                        } else {
                                            imgSrc = "${ctx}/resources/images/"+ suffix+ ".jpg";
                                        }
                                        $('#'+id+ '-upload-more-list').append('<div class="layui-upload-img-div" id="upload_img_'+arr[2]+'"><img src="'+imgSrc+'" title="'+ arr[1] +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\''
	                                        + "${fileHttpPre}"+ arr[3]+ '\');">查看</a><a href="javascript:void(0)" onclick="del(\''
	                                        + arr[2]+'\')";>删除</a></div><p>'+ arr[1]+ '</p><input type="hidden" value="'+preProject+'" id="fileAtt_'+arr[2]+'" name="fileAtt'+id+'" ></input></div>');
                                    }
                                }
                            },
                            allDone : function(obj) {
                                layer.closeAll('loading');
                            },
                            error : function() {
                                layer.closeAll('loading');
                                layer.msg("上传失败，请稍后再试~", {
                                    icon : 7
                                });
                            }
                        });
                }
                uploadRender(20);

                form.on('select(query-select-format-type)', function (data) {
                	if($("#add_select_proId").val()==''||$("#add_select_proId").val()==null){
                		layer.msg('请先选择项目名称', {
                            icon: 0
                        });
                		return;
                	}
                    var items = tableData.filter((el, index) => {
                        return el.pid == data.value;
                    })
                    //获取子div的id值
                    var $table = $("#format-type-table-body");
                    if (items.length > 0) {
                        $table.html('');
                    }
                    var ids = [];
                     $("#mydiv").find("tbody").each(function(){
                        ids.push(this.id);
                      });
                      $.each(ids, function(i,idItem){ 
                    	 $("#"+idItem).html('');
                      });
                    /** 增加里程碑节点  **/
                    $.each(ids, function(i,idItem){
                    	var html = [];
                    	items.forEach((el, index) => {
                            var nextId = index + 1;
                            html.push('<tr id="'+idItem+'Row-' + nextId + '" >');
                            html.push('<td><label>' + nextId + '</label><input type="hidden" value="' + nextId + '" name="showOrderIdx" /></td>');
                            html.push('<input type="hidden" value="' + idItem + '" name="planSubId" />');
                            html.push('<td><label>里程碑节点</label><input type="hidden" value="1" name="levelIdx" /></td>');
                            html.push('<td><label>' + el.name + '</label><input type="hidden" value="' + el.name + '" name="mileName" /></td>');
                            html.push('<td><input type="text" name="memo" lay-verify="required" value="" autocomplete="off" class="layui-input " /></td>');
                            html.push('<td><input type="text" name="planStartTime" lay-verify="required" value="" autocomplete="off" class="layui-input sub-date planstart" /></td>');
                            html.push('<td><input type="text" name="planFinishTime" lay-verify="required" value="" autocomplete="off" class="layui-input sub-date planend" /></td>');
                            html.push('<td><button type="button" class="layui-btn layui-btn-sm"  onclick="addSubRow(this,\''+idItem+'\')"  title="增加管控节点" ><i class="layui-icon">&#xe654;</i></button></td>');
                            html.push('</tr>');
                           // $table.append(html.join(''));                         
                        });
                    	
                        $("#"+idItem).append(html.join(''));
                     });
                    
                    lay('.sub-date').each(function () {
                        laydate.render({
                            elem: this,
                            trigger: 'click',
                            format: 'yyyy-MM-dd'
                        });
                    });
                });

                //项目地点select监听
                form.on('select(add_select_proId)', function (data) {
                    var id = data.value;
                    $('#query-input-buildYear').val('');
                    $('#query-input-omYears').val('');
                    $('#query-input-subName').val('');
                    form.render();
                    if(id==''||id==null){
                    	layer.msg('请选择项目名称',{icon: 0});
			    		return;
                    }else{
                    	getProPlotProId(id);
                    }                   
                });

                //监听提交
                form.on('submit(addInfo_form_submit)',function (data) {
	                if ($("input[name=fileAtt20]").length < 1) {
	                    layer.msg("分区/分段示意图未上传", {
	                        icon : 0
	                    });
	                    return;
	                }
	                $("#addInfo_form_submit").removeAttr("lay-submit").removeClass("layui-bg-blue").addClass("layui-btn-disabled");
	                layer.load();
	                //提交 Ajax 成功后，静态更新表格中的数据
	                $.ajax({
	                    type: 'post',
	                    url: basePath+'/programPlan/save',
	                    data: $('#addInfo_form').serialize(),
	                    success: function (result) {
	                        if (result.success) {
	                            layer.closeAll('loading'); //关闭loading
	                            layer.msg('提交单据成功~',{icon: 1});
	                            //两秒后关闭当前页面
	                            setTimeout(function () {
	                             /**
	                              * 查找父菜单，并刷新
	                              */
	                             var topDoc = $(window.top.document);
	                             var path = basePath + '/ programPlan/list';
	                             // 获取页面名称
	                             var name = topDoc.find(".layui-nav-item [lay-href^='"+ path+ "']").text();
	                             if (name == ''||name == null) {
	                                 name = '项目工程计划';
	                             }
	                             window.parent.layui.index.openTabsPage(path,name);
	                             var iframe = window.parent.layui.admin.tabsBody(window.parent.layui.admin.tabsPage.index).find(".layadmin-iframe");
	                             iframe[0].contentWindow.location.reload(true);
	
	                             /**
	                              * 关闭当前页
	                              */
	                             var currPath = basePath+'/programPlan/add';
	                             var layid = topDoc.find("li[lay-id^='"+currPath+"']").attr('lay-id');
	                             window.parent.layui.element.tabDelete('layadmin-layout-tabs',layid);//关闭当前页
	                         },2000);
	                        } else {
	                            layer.closeAll('loading'); //关闭loading
	                            $("#addInfo_form_submit").removeClass("layui-btn-disabled").addClass("layui-bg-blue").attr("lay-submit","");
	                            layer.msg(result.msg,{icon: 7});
	                        }
	                    }
	                });
                });
                // data-type事件
                $('.layui-btn.layuiadmin-btn-admin').on('click',function () {
	                var type = $(this).data('type');
	                active[type] ? active[type].call(this): '';
                });
            });

    function deleteSubRow(t,idItem) {
        var $ = layui.$;
        layui.layer.confirm('确定删除？', {icon: 3,title: '提示'}, function (index) {
        var $row = $(t).parents('tr[id^=sub'+idItem+'Row]');
        var ID = $row.attr('id');
        $('tr[id="' + ID + '"]').remove();
        var prefix = ID.split('.')[0];
        var $subRows = $("tr[id^=" + prefix + "]");
        var rowId = prefix.split('-')[1];
        $subRows.each(function (index) {
            var sortid = index + 1
            var nextId = rowId + '.' + sortid;
            var nextID = prefix + '.' + sortid;
            $(this).attr('id', nextID).find("label:first").html(nextId).end().find("input[type=hidden]:first").val(nextId);
        });
        layui.layer.close(index);
        });
    }

    function addSubRow(t,idItem) {
        var $ = layui.$;
        var $parentRow = $(t).parents('tr[id^='+idItem+'Row]');
        var parentId = $parentRow.attr('id');
        var $subRows = $("tr[id^=sub" + parentId + "]");
        var $lastRow = $parentRow;
        var count = $subRows.length;
        if (count > 0) {
            $lastRow = $("tr[id^=sub" + parentId + "]:last");
        }
        count++;
        var nextId = 'sub' + parentId + '.' + count;
        var subRowId = nextId.split('-')[1];
        var html = [];
        html.push('<tr id=sub'+idItem+'Row-' + subRowId + ' >');
        html.push('<td><label>' + subRowId + '</label><input type="hidden" value="' + subRowId + '" name="showOrderIdx" /></td>');
        html.push('<input type="hidden" value="' + idItem + '" name="planSubId" />');
        html.push('<td><label>管控节点</label><input type="hidden" value="2" name="levelIdx" /></td>');
        html.push('<td><input type="text" lay-verify="required" value="" autocomplete="off" class="layui-input" name="mileName" /></td>');
        html.push('<td><input type="text" lay-verify="required" value="" autocomplete="off" class="layui-input" name="memo" /></td>');
        html.push('<td><input type="text" lay-verify="required" name="planStartTime" value="" autocomplete="off" class="layui-input sub-date planstart" /></td>');
        html.push('<td><input type="text" lay-verify="required" name="planFinishTime" value="" autocomplete="off" class="layui-input sub-date planend" /></td>');
        html.push('<td><button type="button" class="layui-btn layui-btn-sm"  onclick="deleteSubRow(this,\''+idItem+'\')" ><i class="layui-icon">&#xe640;</i></button></td>');
        html.push('</tr>');
        var medalHtml = html.join('');
        $lastRow.after(medalHtml);
        layui.form.render();
        lay('.sub-date').each(function () {
            laydate = layui.laydate;
            var ins1 = laydate.render({
                elem: this,
                trigger: 'click',
                format: 'yyyy-MM-dd',
                done: function (value, date) {
                    var minStart = $parentRow.find('.planstart').val(),
                    maxEnd = $parentRow.find('.planend').val(),
                    currDate = new Date(value);
                    if ($(this.elem).hasClass('planstart')) {
                        if (minStart != '') {
                            var startDate = new Date(minStart);
                            if (currDate < startDate) {
                                $parentRow.find('.planstart').val(value)
                            }
                        } else {
                            $parentRow.find('.planstart').val(value);
                        }
                    }
                    if ($(this.elem).hasClass('planend')) {
                        if (maxEnd != '') {
                            var startDate = new Date(maxEnd);
                            if (currDate > startDate) {
                                $parentRow.find('.planend').val(value);
                            }
                        } else {
                            $parentRow.find('.planend').val(value);
                        }
                    }
                }
            });
        });
    }

    //删除文件
    function del(index) {
        layui.$("#fileAtt_" + index).remove();
        layui.$("#upload_img_" + index).remove();
    }

    //根据url查看文件
    function showImg(url) {
        var openWin = window.open(url,'','left=410,height=768, width=1024, top=200,  toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
    }

    function getProPlotProId(buildInfoId) {
        var $ = layui.$, form = layui.form
        //获取项目其他信息
        $.ajax({
            type: "POST", //提交方式
            url: "${ctx}/programPlan/getBuildInfoById",//路径
            data: {
                "buildInfoId": buildInfoId
            },//数据，这里使用的是Json格式进行传输
            success: function (result) {//返回数据根据结果进行相应的处理
                if (result.flag == true) {
					$('#query-input-buildYear').val(result.buildInfo.buildYears);
                    $('#query-input-omYears').val(result.buildInfo.omYears);
                    $('#query-input-subName').val(result.buildSubList.subName);
                    var buildSubList = result.buildSubList;
                    $("#mydiv").html('');
                    layui.$.each(buildSubList ,function (i, item){
                    	var  tableTemplate = [];
         				tableTemplate.push('<div class="layui-form-item">');
         				tableTemplate.push('<div class="layui-inline">');
         				tableTemplate.push('<label class="layui-form-label">子项名称</label>');
         				tableTemplate.push('<input type="hidden" value="' + item.id + '" name="subId" />');
         				tableTemplate.push('<input type="hidden" value="' + item.orderIdx + '" name="orderIdx" />');
         				tableTemplate.push('<div class="layui-input-inline">');
         				tableTemplate.push('<input type="text" name="subName" value=" '+item.subName+ ' " id ="query-input-subName" style="border: 0px;" lay-filter="query-input-subName"');
         				tableTemplate.push('readonly="readonly" class="layui-input">');
         				tableTemplate.push('</div>');
         				tableTemplate.push('</div>');
         				tableTemplate.push('</div>');
                        tableTemplate.push(' <div class="layui-col-xs8 layui-col-sm8 layui-col-md9 margin-lt20">');
                        tableTemplate.push('<table class="layui-table">');
                        tableTemplate.push('<colgroup>');
                        tableTemplate.push('<col width="100">');
                        tableTemplate.push('<col width="200">');
                        tableTemplate.push('<col width="200">');
                        tableTemplate.push('<col width="200">');
                        tableTemplate.push('<col width="200">');
                        tableTemplate.push('<col width="200">');
                        tableTemplate.push('<col width="100">');
                        tableTemplate.push('</colgroup>');
                        tableTemplate.push('<thead>');
                        tableTemplate.push('<tr>');
                        tableTemplate.push('<th>序号</th>');
                        tableTemplate.push('<th>节点等级</th>');
                        tableTemplate.push('<th>工作节点</th>');
                        tableTemplate.push('<th>单体/分区说明</th>');
                        tableTemplate.push('<th>计划开始日期</th>');
                        tableTemplate.push('<th>计划完成日期</th>');
                        tableTemplate.push('<th></th>');
                        tableTemplate.push('</tr>');
                        tableTemplate.push('</thead>');
                        tableTemplate.push('<tbody id="'+item.id+'">');	
                        tableTemplate.push('</tbody>');	
                        tableTemplate.push('</table>');	
                        tableTemplate.push('</div>');	
                        var $div = $("#mydiv");
                        $div.append(tableTemplate.join(''));                    	                   	
                    });
                    form.render();
                } else {
                    layer.msg('数据通信异常~', {
                        icon: 0
                    });
                }
            }
        });
    }
</script>
</body>
</html>